/*
 * Create Author  : jinpeng.chen
 * Create Date    : 2016-11-21
 * Project        : spring-boot
 * File Name      : DiConfig.java
 *
 * Copyright (c) 2010-2015 by Shanghai HanTao Information Co., Ltd.
 * All rights reserved.
 *
 */
package com.charles.spring.config;

import com.charles.spring.service.FunctionService;
import com.charles.spring.service.UseFunctionService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 功能描述:  <p>
 *
 * @author : jinpeng.chen <p>
 * @version 1.0 2016-11-21
 * @since spring-boot 1.0
 */
@Configuration
public class DiConfig {

    @Bean
    public FunctionService functionService() {
        return new FunctionService();
    }

   /* @Bean
    public UseFunctionService useFunctionService() {
        UseFunctionService useFunctionService = new UseFunctionService();
        useFunctionService.setFunctionService(functionService());
        return useFunctionService;
    }*/

    /**
     * bean的id就是方法名，这里和上面是一样的，因为参数FunctionService已经让spring管理了，spring会自动注入这个参数
     * @param functionService
     * @return
     */
    @Bean
    public UseFunctionService useFunctionService(FunctionService functionService) {
        UseFunctionService useFunctionService = new UseFunctionService();
        useFunctionService.setFunctionService(functionService);
        return useFunctionService;
    }
}
